import java.util.*;


@SuppressWarnings("serial")
public class OrderedSetImpl<T> extends ArrayList<T> implements OrderedSet<T>{

	public OrderedSetImpl(){
		super();
	}
	
	public OrderedSetImpl(int initialCapacity){
		super(initialCapacity);
	}
	
	public boolean add(T o){
		if(o==null){
			throw new NullPointerException();
		}
		int previousIndex = indexOf(o);
		if(previousIndex!=-1)
			return false;
		else{
			super.add(o);
			return true;
		}
	}

	@Override
	public boolean addAll(Collection<? extends T> c) {
		throw new UnsupportedOperationException();
	}

	@Override
	public boolean addAll(int i, Collection<? extends T> c) {
		throw new UnsupportedOperationException();
	}
	
	public T set(int i, T o){
		if(o==null){
			throw new NullPointerException();
		}
		int previousIndex = indexOf(o);
		if(previousIndex!=-1)
			return null;
		else{
			return super.set(i, o);
		}
	}
	
	public void add(int i, T o){
		if(o==null){
			throw new NullPointerException();
		}
		int previousIndex = indexOf(o);
		if(previousIndex!=-1)
			return;
		else{
			super.add(i, o);
		}
	}
}
